c40514ed8b27fd2378cf8396cc7d598b59fb3602,com.ibm.streamsx.messaging/impl/java/src/com/ibm/streamsx/messaging/jms/ConnectionDocumentParser.java,ConnectionDocumentParser,nativeSchemaChecks,#boolean#StreamSchema#Node#,475

Before Change


				// to typesWithoutLength
				if (typesWithoutLength.contains(nativeAttrType) && nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA) {

					throw new ParseConnectionDocumentException("Length attribute should not be present for parameter: "
							+ nativeAttrName + " In native schema file");
				}

				// Since for xml, wbe and wbe22 all the String, a new check is
				// required

				if ((nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA)
						&& (msgClass == MessageClass.wbe || msgClass == MessageClass.wbe22 || msgClass == MessageClass.xml)
						&& (streamSchema.getAttribute(nativeAttrName) != null)
						&& (streamSchema.getAttribute(nativeAttrName).getType().getMetaType() != Type.MetaType.RSTRING)
						&& (streamSchema.getAttribute(nativeAttrName).getType().getMetaType() != Type.MetaType.USTRING)
						&& (streamSchema.getAttribute(nativeAttrName).getType().getMetaType() != Type.MetaType.BLOB)) {

					throw new ParseConnectionDocumentException("Length attribute should not be present for parameter: "
							+ nativeAttrName + " In native schema file");
				}
				// Since decimal32, decimal64, decimal128 and timestamp are
				// mapped to bytes for message class bytes
				// and in message class bytes, since String/Bytes expect a
				// length, we, set a default length of -4.
				// Add a check that Streamschema has this particular native
				// schema attribute
				if (streamSchema.getAttribute(nativeAttrName) != null) {
					MetaType metaType = streamSchema.getAttribute(nativeAttrName).getType().getMetaType();
					if (metaType == Type.MetaType.DECIMAL32 || metaType == Type.MetaType.DECIMAL64
							|| metaType == Type.MetaType.DECIMAL128 || metaType == Type.MetaType.TIMESTAMP) {
						if (nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA) {
							throw new ParseConnectionDocumentException(
									"Length attribute should not be present for parameter: " + nativeAttrName
											+ " with type " + metaType + " in native schema file.");
						}

						if (msgClass == MessageClass.bytes) {
							nativeAttrLength = -4;
						}
					}
				}
				// Length value should be present if the data type belongs to
				// typesWithLength and message class is bytes
				if (typesWithLength.contains(nativeAttrType)) {
					if (nativeAttrLength == LENGTH_ABSENT_IN_NATIVE_SCHEMA && msgClass == MessageClass.bytes) {
						throw new ParseConnectionDocumentException("Length attribute should be present for parameter: "
								+ nativeAttrName + " In native schema file for message class bytes");
					}
					// Length attribute can be non negative -2,-4 only for
					// message class bytes
					if ((nativeAttrLength < 0) && nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA) {
						if (msgClass != MessageClass.bytes) {

							throw new ParseConnectionDocumentException(
									"Length attribute can be non negative -2,-4 only for message class bytes for parameter: "
											+ nativeAttrName + " In native schema file");

						}
						// If the Length attribute is non negative, it can only
						// be -2,-4 for message class bytes
						if (nativeAttrLength != -2 && nativeAttrLength != -4) {

							throw new ParseConnectionDocumentException(
									"Length attribute should be non negative or -2,-4 for parameter: " + nativeAttrName
											+ " In native schema file");

						}
					}
				}

				// validate if the input port stream schema contains this
				// attributes from the
				// native schema file

				if (streamSchema.getAttribute(nativeAttrName) == null && isProducer == true) {
					// for JMSSink , each and every attribute in
					// native schema
					// should be present in input stream

					throw new ParseConnectionDocumentException("Attribute Name: " + nativeAttrName + " with type:"
							+ nativeAttrType + " in the native schema cannot be found in stream schema ");
				}
				// Here we are comparing the data type of the native schema
				// attribute with the stream schema attribute of the same name
				// and throw an error if a mismatch happens
				String streamAttrName;
				MetaType streamAttrMetaType = null;

				if (streamSchema.getAttribute(nativeAttrName) != null) {
					streamAttrName = streamSchema.getAttribute(nativeAttrName).getName();
					streamAttrMetaType = streamSchema.getAttribute(nativeAttrName).getType().getMetaType();
					// for message classes map and stream
					if ((msgClass == MessageClass.stream || msgClass == MessageClass.map)
							&& !mapSPLToNativeSchemaDataTypesForOtherMsgClass.get(streamAttrMetaType.getLanguageType())
									.equals(nativeAttrType)) {

						throw new ParseConnectionDocumentException("Attribute Name: " + nativeAttrName + " with type:"
								+ nativeAttrType + " in the native schema cannot be mapped with attribute: "
								+ streamAttrName + " with type : " + streamAttrMetaType.getLanguageType());
					}
					// for message class bytes
					else if (msgClass == MessageClass.bytes
							&& !mapSPLToNativeSchemaDataTypesForBytes.get(streamAttrMetaType.getLanguageType()).equals(
									nativeAttrType)) {

						throw new ParseConnectionDocumentException("Attribute Name: " + nativeAttrName + " with type:"
								+ nativeAttrType + " in the native schema cannot be mapped with attribute: "
								+ streamAttrName + " with type : " + streamAttrMetaType.getLanguageType());
					}
					// for message classes xml,wbe,wbe22
					else if ((msgClass == MessageClass.wbe || msgClass == MessageClass.wbe22 || msgClass == MessageClass.xml)
							&& !mapSPLToNativeSchemaDataTypesForText.get(streamAttrMetaType.getLanguageType()).equals(
									nativeAttrType)) {

						throw new ParseConnectionDocumentException("Attribute Name: " + nativeAttrName + " with type:"
								+ nativeAttrType + " in the native schema cannot be mapped with attribute: "
								+ streamAttrName + " with type : " + streamAttrMetaType.getLanguageType());
					} else if (msgClass == MessageClass.text) {
						if (streamAttrMetaType != MetaType.RSTRING && streamAttrMetaType != MetaType.USTRING
								&& streamAttrMetaType != MetaType.XML) {

After Change


				// to typesWithoutLength
				if (typesWithoutLength.contains(nativeAttrType) && nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA) {

					throw new ParseConnectionDocumentException(Messages.getString("LENGTH_ATTRIB_SHOULD_NOT_BE_PRESENT_FOR_PARAM_IN_NATIVE_SCHEMA", nativeAttrName )); //$NON-NLS-1$
				}

				// Since for xml, wbe and wbe22 all the String, a new check is
				// required

				if ((nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA)
						&& (msgClass == MessageClass.wbe || msgClass == MessageClass.wbe22 || msgClass == MessageClass.xml)
						&& (streamSchema.getAttribute(nativeAttrName) != null)
						&& (streamSchema.getAttribute(nativeAttrName).getType().getMetaType() != Type.MetaType.RSTRING)
						&& (streamSchema.getAttribute(nativeAttrName).getType().getMetaType() != Type.MetaType.USTRING)
						&& (streamSchema.getAttribute(nativeAttrName).getType().getMetaType() != Type.MetaType.BLOB)) {

					throw new ParseConnectionDocumentException(Messages.getString("LENGTH_ATTRIB_SHOULD_NOT_BE_PRESENT_FOR_PARAM_IN_NATIVE_SCHEMA", nativeAttrName )); //$NON-NLS-1$
				}
				// Since decimal32, decimal64, decimal128 and timestamp are
				// mapped to bytes for message class bytes
				// and in message class bytes, since String/Bytes expect a
				// length, we, set a default length of -4.
				// Add a check that Streamschema has this particular native
				// schema attribute
				if (streamSchema.getAttribute(nativeAttrName) != null) {
					MetaType metaType = streamSchema.getAttribute(nativeAttrName).getType().getMetaType();
					if (metaType == Type.MetaType.DECIMAL32 || metaType == Type.MetaType.DECIMAL64
							|| metaType == Type.MetaType.DECIMAL128 || metaType == Type.MetaType.TIMESTAMP) {
						if (nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA) {
							throw new ParseConnectionDocumentException(
									Messages.getString("LENGTH_ATTRIB_SHOULD_NOT_BE_PRESENT_FOR_PARAM_WITH_TYPE_IN_NATIVE_SCHEMA", nativeAttrName, metaType )); //$NON-NLS-1$
						}

						if (msgClass == MessageClass.bytes) {
							nativeAttrLength = -4;
						}
					}
				}
				// Length value should be present if the data type belongs to
				// typesWithLength and message class is bytes
				if (typesWithLength.contains(nativeAttrType)) {
					if (nativeAttrLength == LENGTH_ABSENT_IN_NATIVE_SCHEMA && msgClass == MessageClass.bytes) {
						throw new ParseConnectionDocumentException(Messages.getString("LENGTH_ATTRIB_SHOULD_NOT_BE_PRESENT_FOR_PARAM_IN_NATIVE_SCHEMA_FOR_MSG_CLASS_BYTES", nativeAttrName )); //$NON-NLS-1$
					}
					// Length attribute can be non negative -2,-4 only for
					// message class bytes
					if ((nativeAttrLength < 0) && nativeAttrLength != LENGTH_ABSENT_IN_NATIVE_SCHEMA) {
						if (msgClass != MessageClass.bytes) {

							throw new ParseConnectionDocumentException(
									Messages.getString("LENGTH_ATTRIB_CAN_BE_NONNEG-2-4_ONLY_FOR_MSG_CLASS_BYTES_FOR_PARAM_IN_NATIVE_SCHEMA", nativeAttrName )); //$NON-NLS-1$

						}
						// If the Length attribute is non negative, it can only
						// be -2,-4 for message class bytes
						if (nativeAttrLength != -2 && nativeAttrLength != -4) {

							throw new ParseConnectionDocumentException(
									Messages.getString("LENGTH_ATTRIB_SHOULD_BE_NONNEG-2-4_FOR_PARAM_IN_NATIVE_SCHEMA", nativeAttrName )); //$NON-NLS-1$

						}
					}
				}

				// validate if the input port stream schema contains this
				// attributes from the
				// native schema file

				if (streamSchema.getAttribute(nativeAttrName) == null && isProducer == true) {
					// for JMSSink , each and every attribute in
					// native schema
					// should be present in input stream

					throw new ParseConnectionDocumentException(Messages.getString("ATTRIB_WITH_TYPE_IN_NATIVE_SCHEMA_NOT_FOUND_IN_STREAM_SCHEMA", nativeAttrName, nativeAttrType )); //$NON-NLS-1$
				}
				// Here we are comparing the data type of the native schema
				// attribute with the stream schema attribute of the same name
				// and throw an error if a mismatch happens
				String streamAttrName;
				MetaType streamAttrMetaType = null;

				if (streamSchema.getAttribute(nativeAttrName) != null) {
					streamAttrName = streamSchema.getAttribute(nativeAttrName).getName();
					streamAttrMetaType = streamSchema.getAttribute(nativeAttrName).getType().getMetaType();
					// for message classes map and stream
					if ((msgClass == MessageClass.stream || msgClass == MessageClass.map)
							&& !mapSPLToNativeSchemaDataTypesForOtherMsgClass.get(streamAttrMetaType.getLanguageType())
									.equals(nativeAttrType)) {
						throw new ParseConnectionDocumentException(Messages.getString("ATTRIB_WITH_TYPE_IN_NATIVE_SCHEMA_CANNOT_BE_MAPPED_TO_ATTRIB_WITH_TYPE", nativeAttrName, nativeAttrType, streamAttrName, streamAttrMetaType.getLanguageType())); //$NON-NLS-1$
					}
					// for message class bytes
					else if (msgClass == MessageClass.bytes
							&& !mapSPLToNativeSchemaDataTypesForBytes.get(streamAttrMetaType.getLanguageType()).equals(
									nativeAttrType)) {

						throw new ParseConnectionDocumentException(Messages.getString("ATTRIB_WITH_TYPE_IN_NATIVE_SCHEMA_CANNOT_BE_MAPPED_TO_ATTRIB_WITH_TYPE", nativeAttrName, nativeAttrType, streamAttrName, streamAttrMetaType.getLanguageType())); //$NON-NLS-1$
					}
					// for message classes xml,wbe,wbe22
					else if ((msgClass == MessageClass.wbe || msgClass == MessageClass.wbe22 || msgClass == MessageClass.xml)
							&& !mapSPLToNativeSchemaDataTypesForText.get(streamAttrMetaType.getLanguageType()).equals(
									nativeAttrType)) {
						throw new ParseConnectionDocumentException(Messages.getString("ATTRIB_WITH_TYPE_IN_NATIVE_SCHEMA_CANNOT_BE_MAPPED_TO_ATTRIB_WITH_TYPE", nativeAttrName, nativeAttrType, streamAttrName, streamAttrMetaType.getLanguageType())); //$NON-NLS-1$
					} else if (msgClass == MessageClass.text) {
						if (streamAttrMetaType != MetaType.RSTRING && streamAttrMetaType != MetaType.USTRING
								&& streamAttrMetaType != MetaType.XML) {